package com.fr.report.script.core.parser;

import com.fr.base.ColumnRow;

public class ColumnRowLiteral
{
  private ColumnRow targetColumnRow;
  private ColumnRowLocation leftLocation;
  private ColumnRowLocation upLocation;
  private ConditionalOrExpression condition;
  private ConditionalOrExpression start;
  private ConditionalOrExpression end;

  ColumnRowLiteral(ColumnRow paramColumnRow, ColumnRowLocation paramColumnRowLocation1, ColumnRowLocation paramColumnRowLocation2, ConditionalOrExpression paramConditionalOrExpression1, ConditionalOrExpression paramConditionalOrExpression2, ConditionalOrExpression paramConditionalOrExpression3)
  {
    this.targetColumnRow = paramColumnRow;
    this.leftLocation = paramColumnRowLocation1;
    this.upLocation = paramColumnRowLocation2;
    this.condition = paramConditionalOrExpression1;
    this.start = paramConditionalOrExpression2;
    this.end = paramConditionalOrExpression3;
  }

  public boolean isPureColumnRow()
  {
    return ((this.targetColumnRow != null) && (this.leftLocation == null) && (this.upLocation == null) && (this.condition == null) && (this.start == null) && (this.end == null));
  }

  public ColumnRow getTargetColumnRow()
  {
    return this.targetColumnRow;
  }

  public ColumnRowLocation getLeftLocation()
  {
    return this.leftLocation;
  }

  public ColumnRowLocation getUpLocation()
  {
    return this.upLocation;
  }

  public ConditionalOrExpression getCondition()
  {
    return this.condition;
  }

  public ConditionalOrExpression getStart()
  {
    return this.start;
  }

  public ConditionalOrExpression getEnd()
  {
    return this.end;
  }

  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append(this.targetColumnRow);
    if ((this.leftLocation != null) || (this.upLocation != null))
    {
      localStringBuffer.append('[');
      if (this.leftLocation != null)
        localStringBuffer.append(this.leftLocation);
      if (this.upLocation != null)
        localStringBuffer.append(";").append(this.upLocation);
      localStringBuffer.append(']');
    }
    if (this.condition != null)
      localStringBuffer.append('{').append(this.condition).append('}');
    if ((this.start != null) || (this.end != null))
    {
      if (this.condition == null)
        localStringBuffer.append("{}");
      localStringBuffer.append('[').append(this.start).append(':').append(this.end).append(']');
    }
    return localStringBuffer.toString();
  }

  public String getExpression(int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean)
  {
    int i = this.targetColumnRow.getColumn();
    if ((paramInt3 != -1) && (this.targetColumnRow.getColumn() >= paramInt3))
      i += paramInt4;
    int j = this.targetColumnRow.getRow();
    if ((paramInt1 != -1) && (this.targetColumnRow.getRow() >= paramInt1))
      j += paramInt2;
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append(ColumnRow.valueOf(i, j).toString());
    if ((this.leftLocation != null) || (this.upLocation != null))
    {
      localStringBuffer.append('[');
      if (this.leftLocation != null)
      {
        this.leftLocation.changeColumnRow(paramInt1, paramInt2, paramInt3, paramInt4);
        localStringBuffer.append(this.leftLocation);
      }
      if (this.upLocation != null)
      {
        this.upLocation.changeColumnRow(paramInt1, paramInt2, paramInt3, paramInt4);
        localStringBuffer.append(";").append(this.upLocation);
      }
      localStringBuffer.append(']');
    }
    if (this.condition != null)
      localStringBuffer.append('{').append(this.condition.getExpression(paramInt1, paramInt2, paramInt3, paramInt4, false)).append('}');
    if ((this.start != null) || (this.end != null))
    {
      if (this.condition == null)
        localStringBuffer.append("{}");
      localStringBuffer.append('[').append(this.start.getExpression(paramInt1, paramInt2, paramInt3, paramInt4, paramBoolean)).append(':').append(this.end.getExpression(paramInt1, paramInt2, paramInt3, paramInt4, paramBoolean)).append(']');
    }
    return localStringBuffer.toString();
  }

  public String getParameterName()
  {
    return this.targetColumnRow.toString();
  }
}